/*
#Copyright (c) 2013, Philippe Bordron <philippe.bordron@gmail.com>
#
# This file is part of SIPPER.
#
# DCC is free software: you can redistribute it and/or modify
# it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# DCC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU LESSER GENERAL PUBLIC LICENSE for more details.
#
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
# along with SIPPER.  If not, see <http://www.gnu.org/licenses/>
*/
package combi.wip.sipper.modeling;

import java.util.Collection;
import java.util.HashSet;

public class ProteinComplex extends Protein{

	protected Collection<Protein> components;
	
	public ProteinComplex(String id, Collection<Protein> components)
	{
		super(id);
		this.components = new HashSet<Protein>(components);
	}

	@Override
	public Collection<Protein> getComponents() {
		return this.components;
	}
	
	@Override
	public Collection<Protein> getDeepComponents() {
		Collection<Protein> result = new HashSet<Protein>();
		for(Protein p : this.getComponents())
		{
			result.addAll(p.getDeepComponents());
		}
		return result;
	}

	@Override
	public String toString()
	{
		return this.getId() + ":" + getComponents().toString();
	}

	@Override
	public int hashCode() {
		int result =  this.id.hashCode();
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (!super.equals(obj))
			return false;
		if (getClass() != obj.getClass())
			return false;
		ProteinComplex other = (ProteinComplex) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}
}
